package com.moji.controller.api;


import com.moji.common.base.ApiResult;
import com.moji.entity.MjBillAddress;
import com.moji.entity.dto.QueryBillAddressDto;
import com.moji.service.MjBillAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 发票地址表 前端控制器
 * </p>
 *
 * @author ccl
 * @since 2024-08-21
 */
@RestController
@RequestMapping("api/mjBillAddress")
@Api(tags = "发票地址api相关接口", value = "发票地址api相关接口")
public class MjBillAddressController {

    @Resource
    private MjBillAddressService mjBillAddressService;

    @PostMapping("/queryByPage")
    @ApiOperation(value = "分页查询",response = MjBillAddress.class)
    public ApiResult queryByPage(@RequestBody QueryBillAddressDto dto){
        return ApiResult.ok(mjBillAddressService.queryByPage(dto));
    }

    @GetMapping("/detail")
    @ApiOperation(value = "详情",response = MjBillAddress.class)
    public ApiResult detail(@RequestParam("id") Long id){
        return ApiResult.ok(mjBillAddressService.detail(id));
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增",response = Boolean.class)
    public ApiResult add(@Validated @RequestBody MjBillAddress mjBillAddress){
        return ApiResult.ok(mjBillAddressService.add(mjBillAddress));
    }

    @PostMapping("/edit")
    @ApiOperation(value = "编辑",response = Boolean.class)
    public ApiResult edit(@Validated @RequestBody MjBillAddress mjBillAddress){
        return ApiResult.ok(mjBillAddressService.edit(mjBillAddress));
    }

    @GetMapping("/delete")
    @ApiOperation(value = "删除",response = Boolean.class)
    public ApiResult delete(@RequestParam("id") Long id){
        return ApiResult.ok(mjBillAddressService.delete(id));
    }
}

